package com.ctshk.rpc.order.custom.mapper;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ctshk.rpc.order.custom.base.CustomBaseMapper;
import com.ctshk.rpc.order.custom.dto.order.CustomOrderTouristVisaDetailDTO;
import com.ctshk.rpc.order.custom.dto.tourist.CustomOrderTouristVisaListDTO;
import com.ctshk.rpc.order.custom.entity.CustomizedOrderTouristVisa;
import com.ctshk.rpc.order.custom.provider.CustomOrderTouristVisaProvider;
import com.ctshk.rpc.order.custom.req.order.CustomOrderTouristVisaDetailReq;
import com.ctshk.rpc.order.custom.req.tourist.CustomOrderTouristVisaListReq;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

import java.math.BigDecimal;

/**
 * <p>
 * 游客签证记录 Mapper 接口
 * </p>
 *
 * @author 叶冠峰
 * @since 2021-02-22
 */
public interface CustomizedOrderTouristVisaMapper extends CustomBaseMapper<CustomizedOrderTouristVisa> {

    /**
     * 簽證列表
     * @param page
     * @param req
     * @return
     */
    @SelectProvider(type = CustomOrderTouristVisaProvider.class, method = "selectListBySelective")
    IPage<CustomOrderTouristVisaListDTO> selectListBySelective(@Param("page") IPage<CustomOrderTouristVisaListReq> page, @Param("req") CustomOrderTouristVisaListReq req);

    /**
     * 簽證详情
     * @param req
     * @return
     */
    @SelectProvider(type = CustomOrderTouristVisaProvider.class, method = "selectDetailBySelective")
    CustomOrderTouristVisaDetailDTO selectDetailBySelective(@Param("req") CustomOrderTouristVisaDetailReq req);

    /**
     * 可退签证
     * @param touristId
     * @return
     */
    @Select("select ifnull(sum(t.visa_amount), 0) from t_customized_order_tourist_visa t where t.id = #{tourist_id}")
    BigDecimal findAllVisaAmountByTouristId(@Param("tourist_id") Long touristId);
}
